package com.violet.controller.manager;

import com.violet.domain.result.Result;
import com.violet.domain.result.ResultPage;
import com.violet.domain.search.MyPage;
import com.violet.domain.search.manager.MUserSearch;
import com.violet.domain.vo.manager.MUserVo;
import com.violet.service.manager.MUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/manager/user")
@RequiredArgsConstructor
public class MUserController {

    private final MUserService service;

    // 分页获取用户数据
    @GetMapping("/search")
    public ResultPage<List<MUserVo>> search(@ModelAttribute MUserSearch search, @ModelAttribute MyPage myPage) {
        return service.search(search, myPage);
    }

    // 设置某个用户 禁用|启用
    @PutMapping("/{id}")
    public Result<Boolean> setStatus(@PathVariable String id, @RequestParam Boolean status) {
        return Result.success(service.setStatus(id, status), "设置用户状态");
    }

}
